#include "stdafx.h"
#include "t02_C2F.h"


//F=1.8C+32.0
//C=(F-32.0)/1.8

#define F2C(x) (((x) - 32.0) / 1.8)
#define C2F(x) (1.8 * (x) + 32.0)

#define K0C (-273.15)                  //C
#define K0F (-459.67)                  //C
#define CF_FORMAT "%f\t%f\n"

void CF_C2F(double d_from, double d_to, double d_step){
	printf("C\tF\n");
	printf(CF_FORMAT, K0C, C2F(K0C));
	while (d_from < d_to){		
		printf(CF_FORMAT, d_from, C2F(d_from));
		d_from += d_step;
	}
}
void CF_F2C(double d_from, double d_to, double d_step){
	printf("F\tC\n");
	printf(CF_FORMAT, K0F, F2C(K0F));
	while (d_from < d_to){		
		printf(CF_FORMAT, d_from, F2C(d_from));
		d_from += d_step;
	}
}
void t02_CF_func(void){
	double d_step = 10.0;
	double d_from = ((int)K0C)/((int)d_step)*((int)d_step);
	double d_to = 300.0;

	CF_C2F(d_from, d_to, d_step);
	CF_F2C(d_from, d_to, d_step);
}
